package com.cloud.code.集合;

import org.junit.Test;

import java.util.Arrays;
import java.util.BitSet;
import java.util.List;


/**
 * BitSet可以帮助标记 需要删除的list集合中的元素， 并且在你便利的时候，安装下标返回当前下标新的正确的元素。
 */
public class BitSetTest {


    @Test
    public void testBitSet(){

        List<String> list = Arrays.asList(new String[] {"xiaoli","xiaohua","xiaoming","xiaozhang"});
        BitSet set = new BitSet(list.size());

        for (int i = 0; i < list.size(); i++) {
            if("xiaoming".equals(list.get(i)) || "xiaohua".equals(list.get(i))){
                set.set(i);
            }
        }

        System.out.println(set.nextClearBit(1));
    }
}
